//
//  CellForData.m
//  MY Project For Sport
//
//  Created by dllo on 16/1/31.
//  Copyright © 2016年 dilo. All rights reserved.
//

#import "CellForData.h"
#import "ModelForData.h"
#import <DKNightVersion.h>

#define WIDTH self.contentView.frame.size.width
#define HEIGHT self.contentView.frame.size.height

#define WEIGHTT [UIScreen mainScreen].bounds.size.width / 375
#define HEIGHTT [UIScreen mainScreen].bounds.size.height / 667

@interface CellForData ()

@property (nonatomic, retain) UILabel *labelForName;
@property (nonatomic, retain) UILabel *labelForRound;
@property (nonatomic, retain) UILabel *labelForWin;
@property (nonatomic, retain) UILabel *labelForDraw;
@property (nonatomic, retain) UILabel *labelForLose;
@property (nonatomic, retain) UILabel *labelForTruegoal;
@property (nonatomic, retain) UILabel *labelForCount;


@end

@implementation CellForData
- (void)dealloc {
    [_labelForName release];
    [_labelForRound release];
    [_labelForWin release];
    [_labelForDraw release];
    [_labelForLose release];
    [_labelForTruegoal release];
    [_labelForCount release];
    [_labelForOrder release];
    
    [super dealloc];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {

    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if ( self ) {
        
        self.contentView.dk_backgroundColorPicker = DKColorWithRGB(0xffffff, 0x343434);

        [self createSubview];
        
    }
    return self;

}

- (void)createSubview {
  
    self.labelForOrder = [[UILabel alloc] init];
    [self.contentView addSubview:self.labelForOrder];
    [_labelForOrder release];
    
    self.labelForCount = [[UILabel alloc] init];
    [self.contentView addSubview:self.labelForCount];
    [_labelForCount release];
    
    self.labelForDraw = [[UILabel alloc] init];
    [self.contentView addSubview:self.labelForDraw];
    [_labelForDraw release];
    
    self.labelForLose = [[UILabel alloc] init];
    [self.contentView addSubview:self.labelForLose];
    [_labelForLose release];
    
    self.labelForRound = [[UILabel alloc] init];
    [self.contentView addSubview:self.labelForRound];
    [_labelForRound release];
    
    self.labelForName = [[UILabel alloc] init];
    [self.contentView addSubview:self.labelForName];
    [_labelForName release];
    
    self.labelForTruegoal = [[UILabel alloc] init];
    [self.contentView addSubview:self.labelForTruegoal];
    [_labelForTruegoal release];
    
    self.labelForWin = [[UILabel alloc] init];
    [self.contentView addSubview:self.labelForWin];
    [_labelForWin release];
    
}

- (void)layoutSubviews {

    [super layoutSubviews];
    
    self.labelForOrder.frame = CGRectMake(10 * WEIGHTT, WIDTH / 28, WIDTH / 15, WIDTH / 15);
    self.labelForOrder.layer.cornerRadius = WIDTH / 30;
    self.labelForOrder.layer.masksToBounds = YES;
   // self.labelForOrder.backgroundColor = [UIColor redColor];
    self.labelForOrder.dk_textColorPicker = DKColorWithColors([UIColor blackColor], [UIColor whiteColor]);
    
    
    self.labelForName.frame = CGRectMake(WIDTH / 15 + 20 * WEIGHTT, WIDTH / 28, WIDTH / 4, WIDTH / 15);
    self.labelForName.dk_textColorPicker = DKColorWithColors([UIColor blackColor], [UIColor whiteColor]);
    

   // self.labelForName.backgroundColor = [UIColor grayColor];
    
    self.labelForRound.frame = CGRectMake(WIDTH / 15 + WIDTH / 4 + 30 * WEIGHTT, WIDTH / 28, WIDTH / 13, WIDTH / 15);
    self.labelForRound.dk_textColorPicker = DKColorWithColors([UIColor blackColor], [UIColor whiteColor]);
    //self.labelForRound.backgroundColor = [UIColor greenColor];
    
    
    self.labelForWin.frame = CGRectMake(WIDTH / 15 + 40 * WEIGHTT + WIDTH / 4 + WIDTH / 13, WIDTH / 28, WIDTH / 16, WIDTH / 15);
    self.labelForWin.dk_textColorPicker = DKColorWithColors([UIColor blackColor], [UIColor whiteColor]);
    

    //self.labelForWin.backgroundColor = [UIColor cyanColor];
    
    self.labelForDraw.frame = CGRectMake(43 * WEIGHTT + WIDTH / 15 + WIDTH / 4 + WIDTH / 13 + WIDTH / 16, WIDTH / 28, WIDTH /16 , WIDTH / 15);
    self.labelForDraw.dk_textColorPicker = DKColorWithColors([UIColor blackColor], [UIColor whiteColor]);
    


    self.labelForLose.frame = CGRectMake(46 * WEIGHTT + WIDTH / 15 + WIDTH / 4 + WIDTH / 13 + WIDTH / 16 * 2, WIDTH / 28 , WIDTH / 16, WIDTH / 15);
    self.labelForLose.dk_textColorPicker = DKColorWithColors([UIColor blackColor], [UIColor whiteColor]);
    

   // self.labelForLose.backgroundColor = [UIColor yellowColor];
    
    self.labelForTruegoal.frame = CGRectMake(46 * WEIGHTT + WIDTH / 15 + WIDTH / 4 + WIDTH / 13 * 4, WIDTH / 28, WIDTH / 13, WIDTH / 15);
    self.labelForTruegoal.dk_textColorPicker = DKColorWithColors([UIColor blackColor], [UIColor whiteColor]);
    

   // self.labelForTruegoal.backgroundColor = [UIColor blueColor];
    
    self.labelForCount.frame = CGRectMake(46 * WEIGHTT + WIDTH / 20 + WIDTH / 15 + WIDTH / 4 + WIDTH / 13 * 5, WIDTH / 28, WIDTH / 13, WIDTH / 15);
    self.labelForCount.dk_textColorPicker = DKColorWithColors([UIColor blackColor], [UIColor whiteColor]);
    

   // self.labelForCount.backgroundColor = [UIColor purpleColor];

}

-(void)passModelForData:(ModelForData *)model {

    self.labelForOrder.text = [NSString stringWithFormat:@"%ld", model.team_order];
    self.labelForOrder.textAlignment = NSTextAlignmentCenter;
    self.labelForName.text = model.team_cn;
    self.labelForRound.text = model.count;
    self.labelForWin.text = model.win;
    self.labelForDraw.text = model.draw;
    self.labelForLose.text = model.lose;
    self.labelForTruegoal.text = model.truegoal;
    self.labelForCount.text = model.score;

}



- (void)awakeFromNib {
    // Initialization code
    
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
